<script setup lang="ts">
import { useCounterStore } from '@/store';
import { computed, ref } from 'vue'

defineProps<{ msg: string }>()

// const count = ref(0)

const store = useCounterStore();

const count = computed(() => store.getCount) // 通过computed()动态计算，将count定以为响应式的，store.increment中值的变化会引起count跟着改变，页面中的count也会跟着更新
// const count =  store.getCount // 这样写count不是响应式的，但是store.increment()也能成功修改其在store里的值，只是页面中的count不会跟着变化

const increCount = ()=>{
  store.increment();
}
</script>

<template>
  <h1>{{ msg }}</h1>

  <el-button @click="increCount">Default</el-button>
  <el-button type="primary">Primary</el-button>

  <el-icon :size="20">
    <Edit/>
  </el-icon>
  <div class="card">
    <button type="button" @click="count++">count is {{ count }}</button>
    <p>
      Edit
      <code>components/HelloWorld.vue</code> to test HMR
    </p>
  </div>

  <p>
    Check out
    <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
      >create-vue</a
    >, the official Vue + Vite starter
  </p>
  <p>
    Install
    <a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
    in your IDE for a better DX
  </p>
  <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>
